//
// Copyright (c) 2024 BPer
//

#include <bperrtp/BPerRtpBuffer.h>
#include <bperrtp/BPerRtpConstant.h>

void bPer_create_rtpBuffer(BPerRtpBuffer* rtpbuf,int pbuflen,int unitsize){
	if(rtpbuf==NULL) return;
	rtpbuf->bufLen=pbuflen;
	rtpbuf->index=0;
	rtpbuf->buffer=(char*)bPer_calloc(unitsize*rtpbuf->bufLen,1);
}
void bPer_destroy_rtpBuffer(BPerRtpBuffer* rtpbuf){
	if(rtpbuf==NULL) return;
	bPer_free(rtpbuf->buffer);
}
char* bPer_get_rtpBuffer(BPerRtpBuffer* rtpbuf){
	if(rtpbuf==NULL) return NULL;
	rtpbuf->index++;
	if(rtpbuf->index>=rtpbuf->bufLen) rtpbuf->index=0;
	return rtpbuf->buffer+kRtpPacketSize*rtpbuf->index;
}



